package butines.core;



import java.awt.Graphics2D;

public class GameCursor {

	private float countdown;
	private int frame;
	
	private GameImage[] frames;
	private GameImage curr;
	
	public GameCursor(GameImage image) {
		frames = image.split(128, 128);
		curr = frames[0];
		for (int i = 0; i < frames.length; i++) {
			frames[i].center();
		}
	}

	public void update(float delta) {
	    countdown += delta;
        if (countdown >= .1f) {
            countdown %= .1f;
            frame = (frame + 1 >= frames.length) ? 0 : frame + 1;
            curr = frames[frame];
        }
	}
	
	public void render(Graphics2D g2d, float sx, float sy) {
		curr.draw(g2d, sx, sy);
	}
	
}
